package control
{
	import control.panel.PanelControl;
	
	import flash.events.Event;
	
	import view.components.ModulLoader;
	import view.panel.BankPanel;
	import global.GameState;
	
	public class BankPanelControl extends PanelControl
	{
		private var bankModulLoader:ModulLoader;
		
		
		public function BankPanelControl()
		{
			initPanel();
			initModulLoader();
		}
		
		private function initModulLoader():void
		{
			bankModulLoader = new ModulLoader(700,360);
			bankModulLoader.x = 10;
			bankModulLoader.y = 40;
			_view.bankPanel.addChild(bankModulLoader);
			bankModulLoader.addEventListener(Event.COMPLETE,onComplete);
		}
		
		private function onComplete(event:Event):void
		{
			event.target.removeEventListener(Event.COMPLETE,onComplete);
			bankModulLoader.content.init(GameState.snsId);
		}
		
		private function initPanel():void
		{
			_view.bankPanel = new BankPanel(this);
		}
		
		public function open():void
		{
			if ( !bankModulLoader.isLoading && !bankModulLoader.isComplete)
			{
				bankModulLoader.load("BankLand.swf");
			}
			
			if (bankModulLoader.isComplete)
			{
				bankModulLoader.content.init(GameState.snsId);
			}
			_view.bankPanel.open();
			
			//_control.brokenPanelControl.open();
		}
	}
}